package service;

import util.CheckParameters;
import dao.BalanceMonthDAO;
import domain.BalanceMonth;
import exception.InvalidBusinessStateException;

public class BalanceMonthService extends GenericService<BalanceMonth> {

	private static BalanceMonthService instance;
	
	public static BalanceMonthService getInstance() {
		if (instance == null)
			instance = new BalanceMonthService();
		return instance;
	}
	
	public BalanceMonthService() {
		dao = BalanceMonthDAO.getInstance();
	}

	@Override
	protected void businessRules(BalanceMonth balanceMonth)
			throws InvalidBusinessStateException {
		CheckParameters.checkStringEmpty(balanceMonth.getDateStart(), "Date of start");
	}

	@Override
	protected void handleDependencies(BalanceMonth entity)
			throws InvalidBusinessStateException {
	}

	@Override
	protected void cascadeDeletion(Integer id) throws InvalidBusinessStateException {
		// TODO Auto-generated method stub
		
	}

	public BalanceMonth getCurrentBalanceMonth() {
		return ((BalanceMonthDAO) dao).getCurrentBalanceMonth();
	}
}
